/**
 * This class is designed to be used in both website and android.
 * <p/>
 * zhaoxu @ 2012-05-24 12:20
 * <p/>
 */
package com.threeti.mecool.core.domain.model.plan.pojo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.codehaus.jackson.annotate.JsonManagedReference;

public class RouteStep extends Step {
	private List<RouteStepItem> items = new ArrayList<RouteStepItem>(0);
	
	public RouteStepItem getItemByRouteStepItemId(long id) {
		for (RouteStepItem item : items) {
			if (id == item.getId()) {
				return item;
			}
		}
		return null;
	}
	
	/**
	 * @return unmodifiableList
	 */
	@JsonManagedReference
	public List<RouteStepItem> getItems() {
		return Collections.unmodifiableList(items);
	}
	
	public RouteStepItem newItem() {
		RouteStepItem item = new RouteStepItem();
		items.add(item);
		item.setRouteStep(this);
		return item;
	}
}
